package cn.yunhe.action;

import cn.yunhe.entity.Book;
import cn.yunhe.service.BookService;
import cn.yunhe.util.BaseAction;
import com.mysql.jdbc.Blob;

import java.io.File;
import java.io.FileInputStream;


/**
 * Created by Administrator on 2018/4/13.
 */
public class AddBookAction extends BaseAction{
    private static  final long serialVersionUID=4230186551226007292L;
    private String isbn;
    private String name;
    private String author;
    private String publish;
    private int price;
    private int currcount;
    private Blob picture;


    public String execute() throws Exception {
        if(picture!=null){
            FileInputStream fis=new FileInputStream(String.valueOf(picture));

        }
        BookService bookService=new BookService();
        Book book=new Book(isbn,name,author,publish,price,currcount,picture);
        int flag=bookService.addBook(book);
        if(flag>0){
            return SUCCESS;
        }else {
            return ERROR;
        }

    }

    public String getIsbn() {
        return isbn;
    }

    public void setIsbn(String isbn) {
        this.isbn = isbn;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getPublish() {
        return publish;
    }

    public void setPublish(String publish) {
        this.publish = publish;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public int getCurrcount() {
        return currcount;
    }

    public void setCurrcount(int currcount) {
        this.currcount = currcount;
    }

    public Blob getPicture() {
        return picture;
    }

    public void setPicture(Blob picture) {
        this.picture = picture;
    }
}